package com.supermap.agricultural_meteoro.monitor.service.impl;

import com.supermap.agricultural_meteoro.monitor.common.ResponseData;
import com.supermap.agricultural_meteoro.monitor.dao.SPSSDao;
import com.supermap.agricultural_meteoro.monitor.entity.SPSS;
import com.supermap.agricultural_meteoro.monitor.service.SPSSService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SPSSServiceImpl implements SPSSService {

    protected static final Logger logger = LoggerFactory.getLogger(SPSSServiceImpl.class);

    @Resource
    private SPSSDao spssDao;

    @Override
    public ResponseData getUserSPSSInformation(String userId) {
        //初始化Json封装工具类
        ResponseData responseData = new ResponseData();
        try {
            List<SPSS> news = spssDao.getUserSPSSInformation(userId);
            responseData.setMsg("Get newmessage success！");
            responseData.setIsSuccess(true);
            responseData.setCode(200);
            responseData.setData(news);
        } catch (Exception e) {
            //捕捉数据库异常
            logger.error("SPSSServiceImpl=>getUserSPSSInformation=>DaoException:" + e.getMessage());
            responseData.setMsg("Get newmessage flase！");
            responseData.setIsSuccess(false);
            responseData.setCode(100);
        }
        return responseData;
    }
}
